import requests
import re
from util.fonts import get_font_maps
font_path = './static/fonts/maoyan.woff'
url = "https://piaofang.maoyan.com/dashboard-ajax/movie?movieId=1528577&orderType=0&uuid=19a95c6ac16c8-0c61a5fd5e20dc8-26061851-1fa400-19a95c6ac17c8&timeStamp=1763449440902&User-Agent=TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzE0MS4wLjAuMCBTYWZhcmkvNTM3LjM2&index=120&channelId=40009&sVersion=2&signKey=854d7846b42f6caa3e295ed6835c44d6&WuKongReady=h5"
res = requests.get(url, headers={
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36'
})
for item in res.json()['movieList']['list']:
    print(item['boxSplitUnit']['num'], item['movieInfo']['movieName'])
    break
font_url = re.search(r'\),url\("(.*?)"\);}',res.json()['fontStyle'])
if font_url:
    font_url = f'https:{font_url.group(1)}'
    font_res = requests.get(font_url)
    with open(font_path,'wb')as f:
        f.write(font_res.content)

font_maps = get_font_maps(font_path)
